/**
  ******************************************************************************
  * @file    Bsp/Fram.h
  * @author  Mr_zai
  * @version V1.0
  * @date    2019-5-16
  * @brief   Fram.c module
  */

/* Define to prevent recursive inclusion -------------------------------------*/

#ifndef __FRAM_H
#define __FRAM_H

/* Includes ------------------------------------------------------------------*/
	#include "main.h"

/* Exported constants --------------------------------------------------------*/

//the FRAM RCC clock at APB1 part
#define I2C_RCC_APB1_CLOCK  		( RCC_APB1Periph_I2C1 )

//the Two Interface
#define I2C_USED   					( I2C1 )
#define I2C_GPIO     				( GPIOB )
#define I2C_SCL_PIN      			( GPIO_Pin_6 )
#define I2C_SDA_PIN      			( GPIO_Pin_7 )
#define I2C_SCL_PS					( GPIO_PinSource6 )
#define I2C_SDA_PS					( GPIO_PinSource7 )

/* Exported macro ------------------------------------------------------------*/

//the FRAM GPIO for WP pin
//the Write Protection Pin, when WP is high the entire array is write protected.
#define FRAM_WP_GPIO    			( GPIOB )
#define FRAM_WP_PIN      			( GPIO_Pin_5 )
#define FRAM_WP_ENABLE      		( GPIO_SetBits(FRAM_WP_GPIO, FRAM_WP_PIN) )
#define FRAM_WP_DISABLE       		( GPIO_ResetBits(FRAM_WP_GPIO, FRAM_WP_PIN) )


/* Exported functions --------------------------------------------------------*/

extern void Fram_Init( void );

// Public function of the device of Fram_MB85RC16
extern ErrorStatus Fram_MB85RC16_Status( void );
extern void Fram_Write_Byte(u16 WordAddress, u8 ByteVal);
extern void Fram_Write_Word(u16 WordAddress, u16 WordVal);
extern u8 Fram_Read_Byte(u16 WordAddress);
extern u16 Fram_Read_Word(u16 WordAddress);
extern void Fram_Data_Init( void );


#endif /* __FRAM_H */


